import React from 'react';
import { Router, Route, routerRedux } from 'dva/router';
import App from './routes/app';
import Index from './routes/index';
import routerPartOne from './routerPart1';
import routerPartTwo from './routerPart2';
import { onRouteEnter } from './utils/auth';

import Login from './routes/account/login';
import NotAuthority from './routes/exception/notauthority';

export const routes = (
  <div>
    {/* 如果需要拦截请求并验证授权，则需要添加 onEnter={onRouteEnter} */}
    <Route component={App} >
      <Route path='/403' component={NotAuthority} />
      <Route path='/' component={Index} onEnter={onRouteEnter} />
      {routerPartOne}
      {routerPartTwo}
    </Route>
    <Route path='/login' component={Login}></Route>
  </div>
);


export default function ({ history }) {
  return (
    <Router history={history}>
      {routes}
    </Router>
  );
}
